package com.lykj.lib_base.internal.utils

import com.blankj.utilcode.util.SPStaticUtils
import com.blankj.utilcode.util.Utils
import com.bun.miitmdid.core.MdidSdkHelper

/**
 * oaid获取辅助类
 */
object oaidHelper {
    private var oaid = ""

    open fun getOaid(): String {
        if (oaid.isNullOrBlank()) {
            oaid = SPStaticUtils.getString("oaid", "")
        }
        if (oaid.isNullOrBlank()) {
            init()
        }
        return oaid
    }

    open fun init() {
        MdidSdkHelper.InitSdk(
            Utils.getApp(), true
        ) { p0, p1 ->
            if (!p0 || p1 == null || !p1.isSupported) {
                return@InitSdk
            }

            oaid = p1.oaid
            SPStaticUtils.put("oaid", oaid)
        }
    }
}